package ca.concordia.soen6011.tests;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import ca.concordia.soen6011.Result;
import ca.concordia.soen6011.exceptions.InfinityOutputException;
import ca.concordia.soen6011.exceptions.UndefinedOutputException;
import ca.concordia.soen6011.impl.Sin;
import ca.concordia.soen6011.interfaces.MathFunction;

public class TestSin {
	
	private  MathFunction f;
	
	@Before
	public void setUp(){
		f = new Sin();
	}
	
	@Test
	public void doTest(){
		
		Result r = new Result();
		try{
		r = f.compute(90, 2);
		assertEquals(1, r.getOutput(), r.getPrecision());
		
		r = f.compute(-90, 2);
		assertEquals(-1, r.getOutput(), r.getPrecision());
		
		r = f.compute(50,1);
		assertEquals(0.71, r.getOutput(), r.getPrecision());
		
		r = f.compute(180,4);
		assertEquals(0, r.getOutput(), r.getPrecision());
		
		r = f.compute(Math.E,3);		
		assertEquals(0.0474, r.getOutput(), r.getPrecision());
		
		r = f.compute(Math.E,1);		
		assertEquals(0.0, r.getOutput(), r.getPrecision());
		
		r = f.compute(- Math.E,1);		
		assertEquals(0.0, r.getOutput(), r.getPrecision());
		
		} catch (InfinityOutputException | UndefinedOutputException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	

}
